export default {
    // getters 类似于计算属性
    powerCount(state) {
        return state.count * state.count;
    },
    studentsMessage(state) {
        return state.students;
    },
    greaterAgesCount: state => {
        // return state.students.filter(s => s.age >= 20).length;
        return state.students.filter(s => s.age >= 20);
    },
    greaterAgesCountLength: (state, getters) => {
        // return state.students.filter(s => s.age >= 20).length;
        return getters.greaterAgesCount.length;
    },
    // 获取年龄大于age的学生
    // moreAgesStu(state) {
    //     // return function(age) {
    //     //     return state.students.filter(s => s.age >= age);
    //     // };
    //     return age => { return state.students.filter(s => s.age >= age) };
    // },
    // 没把return去掉是增加代码可读性
    moreAgesStu: state => {
        return age => {
            return state.students.filter(s => s.age >= age);
        }
    }
}